package com.cloudsigns.factorymanager2.produce.presenter.produce_team;

import android.os.Handler;

import com.cloudsigns.factorymanager2.produce.iview.produce_team.IApplyScrapFeedbackView;
import com.cloudsigns.factorymanager2.produce.model.produce_team.ApplyScrapFeedbackModel;
import com.cloudsigns.factorymanager2.produce.model.produce_team.IApplyScrapFeedbackModel;

public class ApplyScrapFeedbackPresenter {
    private IApplyScrapFeedbackView view;
    private IApplyScrapFeedbackModel model;
    private Handler handler = new Handler();

    public ApplyScrapFeedbackPresenter(IApplyScrapFeedbackView view) {
        this.view = view;
        this.model = new ApplyScrapFeedbackModel();
    }

    public void applyScrapFeedback() {
        model.applyScrapFeedback(view.getAmount(), view.getContent(), view.getImgUrlList(), view.getOrderId(), view.getProductId(), view.getWorkPartId(), view.getWorkPartOrderId(), new ApplyScrapFeedbackModel.OnApplyScrapFeedbackListener() {
            @Override
            public void successed() {
                handler.post(new Runnable() {
                    @Override
                    public void run() {
                        view.applyScrapFeedbackSuccessed();
                        view.hideLoading();
                    }
                });
            }

            @Override
            public void failed(String desc) {
                view.applyScrapFeedbackFailed(desc);
                view.hideLoading();
            }
        });
    }
}
